""""""
import time

from page.Shopping_cart_page import Shopping_cart_page
from page.order_login_page import Order_login_page
from page.order_num_page import Oder_num_page
from sctripts.user_center_script import Get_order_num

"""下订单流程"""

"""导包"""
from common.base import open_browser,Base
from page.buy_now_page import BuyNow_page
from page.home_page import Home_page,url

from page.order_page import SubmitOrder_page




class Order_script(object):

    def __init__(self,driver):
        """实列化类和浏览器"""
        self.order=SubmitOrder_page(driver)
        self.home=Home_page(driver)
        self.buy_now=BuyNow_page(driver)
        self.login=Order_login_page(driver)
        self.shopping_cart=Shopping_cart_page(driver)
        self.order=SubmitOrder_page(driver)
        self.submit_order=SubmitOrder_page(driver)
        self.user_order=Get_order_num(driver)
        self.submit_order.open_url(url)
        self.order=Oder_num_page(driver)




    def pay_by_balance(self):
        """使用余额付款"""

        #点击手表
        self.home.click_goods()
        time.sleep(5)
        #点击立即购买
        self.buy_now.click_buy_now()
        time.sleep(5)
        #点击去结算
        self.shopping_cart.click_check_out()
        time.sleep(5)
        #点击提交
        self.submit_order.click_submit_order()

    def is_success_flow(self):
        """判断是否成功"""
        try:
            res=self.order.get_num()

            res1=self.user_order.get_order_number_flow()



            if res==res1:
                print("购买成功")

            else:
                return False
        except Exception as e:
            return e









